﻿<cfsilent>
	<cfscript>
	
		/* 各学院四级通过率排名 */
		sql = "SELECT 
				institute_id, institute_name, 
				student_taken, student_passed, student_good 
				FROM mv_institute_cet_status 
				WHERE 
					exam_id = :examId 
					AND 
					student_taken > 0 
					AND 
					student_passed > 0";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="examId", value="CET4", cfsqltype="cf_sql_char" );

		rs_cet4 = queryObj.execute( sql=sql ).getResult();
		
		
		cet4sortArray = [];
		
		/* 循环生成通过率 */
		for( a=1; a LTE rs_cet4.recordCount; a++ ){
			arrayAppend( cet4sortArray, [ rs_cet4["institute_id"][a], rs_cet4["institute_name"][a], numberFormat(100*rs_cet4["student_passed"][a]/rs_cet4["student_taken"][a], "__._"), numberFormat(100*rs_cet4["student_good"][a]/rs_cet4["student_taken"][a], "__._") ] );
		}
		
		
		for ( outer=1; outer lte arrayLen(cet4sortArray); outer++ ) {
			for ( inner=1; inner lte arrayLen(cet4sortArray)-1; inner++ ) {
				if ( cet4sortArray[inner][3] lt cet4sortArray[outer][3] ) {
					arraySwap( cet4sortArray, outer, inner );
				}
			}
		}
		
		/* 各学院六级通过率排名 */
		sql = "SELECT 
				institute_id, institute_name, 
				student_taken, student_passed, student_good 
				FROM mv_institute_cet_status 
				WHERE 
					exam_id = :examId 
					AND 
					student_taken > 0 
					AND 
					student_passed > 0";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="examId", value="CET6", cfsqltype="cf_sql_char" );

		rs_cet6 = queryObj.execute( sql=sql ).getResult();
		
		cet6sortArray = [];
		
		/* 循环生成通过率 */
		for( a=1; a LTE rs_cet6.recordCount; a++ ){
			arrayAppend( cet6sortArray, [ rs_cet6["institute_id"][a], rs_cet6["institute_name"][a], numberFormat(100*rs_cet6["student_passed"][a]/rs_cet6["student_taken"][a], "__._"), numberFormat(100*rs_cet6["student_good"][a]/rs_cet6["student_taken"][a], "__._") ] );
		}
		
		for ( outer=1; outer lte arrayLen(cet6sortArray); outer++ ) {
			for ( inner=1; inner lte arrayLen(cet6sortArray)-1; inner++ ) {
				if ( cet6sortArray[inner][3] lt cet6sortArray[outer][3] ) {
					arraySwap( cet6sortArray, outer, inner );
				}
			}
		}
		
	</cfscript>
</cfsilent>

<div class="UIDashBoard">
	
	<div class="col2">
		
		<div class="noticeBlock">
			<h3>四级通过率排名</h3>
		</div>
		
		<table class="UItable">
			<tr class="cellBorder">
				<td align="center">排名</td>
				<td>学院</td>
				<td align="center">通过率</td>
				<td align="center">优秀率</td>
			</tr>
			<cfset row = 0 />
			<cfloop array="#cet4sortArray#" index="entity">
				<cfset row++ />
				<tr class="cellBorder">
					<td align="center"><span class="number"><cfoutput>#row#</cfoutput></span></td>
					<td><cfoutput>#entity[2]#</cfoutput></td>
					<td align="center"><span class="number"><cfoutput>#entity[3]#</cfoutput> %</span></td>
					<td align="center">
						<cfif entity[4] gt 0>
							<span class="number"><cfoutput>#entity[4]#</cfoutput> %</span>
						</cfif>
					</td>
				</tr>
			</cfloop>
		</table>
		
	</div>
	
	<div class="col2 last">
		
		<div class="noticeBlock">
			<h3>六级通过率排名</h3>
		</div>
		
		<table class="UItable">
			<tr class="cellBorder">
				<td align="center">排名</td>
				<td>学院</td>
				<td align="center">通过率</td>
				<td align="center">优秀率</td>
			</tr>
			<cfset row = 0 />
			<cfloop array="#cet6sortArray#" index="entity">
				<cfset row++ />
				<tr class="cellBorder">
					<td align="center"><span class="number"><cfoutput>#row#</cfoutput></span></td>
					<td><cfoutput>#entity[2]#</cfoutput></td>
					<td align="center"><span class="number"><cfoutput>#entity[3]#</cfoutput> %</span></td>
					<td align="center">
						<cfif entity[4] gt 0>
							<span class="number"><cfoutput>#entity[4]#</cfoutput> %</span>
						</cfif>
					</td>
				</tr>
			</cfloop>
		</table>
		
	</div>
</div>
